public class Solution {
    //前后指针法
    public int removeElement(int[] nums, int val) {
        int left=0;
        int right=0;
        int n=nums.length;
        while(right<n){
            if(nums[right]!=val){
                nums[left]=nums[right];
                left++;
            }
            right++;
        }
        return left;
    }
}